package org.lgiavedoni.android.franq.command.general;

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Options;
import org.lgiavedoni.android.franq.core.command.Command;
import org.lgiavedoni.android.franq.core.question.Question;
import org.lgiavedoni.android.franq.service.communication.CommunicationService;
import org.lgiavedoni.android.franq.service.question.QuestionService;
import org.lgiavedoni.android.franq.service.question.dao.QuestionDAO;

public class QuestionCommand extends Command {

	@Override
	public void setOptions(Options options) {

	}

	@Override
	public boolean execute(CommandLine cmd) throws Exception {
		Question q = QuestionDAO.inst.getNextQuestion();
		while (q != null) {
			QuestionService.inst.askNowAndWait(q);
			q = QuestionDAO.inst.getNextQuestion();

		}

		CommunicationService.inst.sendDefaultTextMessage("Sorry, I don't have more questions for you.");
		return true;
	}

	@Override
	public String getCommandText() {
		return "questions";
	}
}